package com.imooc.controller;

import com.imooc.properties.GirlProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by echo on 2017/5/8.
 */
@RestController
@RequestMapping("/test")
public class HelloController
{
    @Autowired
    private GirlProperties girlProperties;

    /*@Value("${cupSize}")
    private  String cupSize;

    @Value("${age}")
    private Integer age;

    @Value("${content}")
    private  String content;*/
    @GetMapping(value = "/index")
    public ModelAndView index()
    {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index");
        return modelAndView;
    }

    @RequestMapping(value = {"/hello", "/hi"}, method = RequestMethod.GET)
    public String say()
    {
        return  "Hello Spring Boot!" + "<br/>" + girlProperties.toString();
    }
    @RequestMapping(value = "/say/{id}", method = RequestMethod.GET)
    public String hi(@PathVariable("id") Integer id)
    {
        return "id: " + id;
    }
    //@RequestMapping(value = "/say", method = RequestMethod.GET)
    @GetMapping(value = "/say")
    public String hello(@RequestParam(value = "id", required = false, defaultValue = "0") Integer tid)
    {
        return "id: " + tid;
    }
    @GetMapping(value = "/lazyloading")
    public ModelAndView lazyloading()
    {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("lazyloading/lazyload-image");
        return modelAndView;
    }
}















